package bookdemo.dao.service;

import bookdemo.domain.Book;
import bookdemo.service.BookService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class BookServiceTestCase {
    @Autowired
    private BookService bookService;

    @Test
    void testGetById(){
        System.out.println(bookService.getById(1));
    }

    @Test
    void TestUpdate(){
        Book book = new Book();
        book.setId(9);
        book.setName("书x02");
        bookService.update(book);

    }


    @Test
    void TestDelete(){
        bookService.delete(9);

    }


    @Test
    void TestGetall(){

        System.out.println(bookService.getAll());
    }


    @Test
    void TestGetPage(){
        IPage page =new Page(1,5);
        bookService.getPage(2,3);

    }

//
//    @Test
//    void TestGetBy(){
//        QueryWrapper<Book> qw = new QueryWrapper<>();
////        if (name!-null)
//        qw.like("name","3");
//        bookDao.selectList(qw);
//
//    }
//    @Test
//    void TestGetBy2(){
//        LambdaQueryWrapper<Book> lqw = new LambdaQueryWrapper<>();
//        String namelike = "3";
//        lqw.like(true,Book::getName,namelike);
//        bookDao.selectList(lqw);
//
//    }

}
